/* JSON */
const data = {
  current: 0,
  rules: {},
  form: {},
  list: [
    {
      name: "基本信息",
      list: [
        {
          key: "name",
          name: "供应商名称",
          type: "text",
          required: true,
          disabled: true,
          row: 8,
          isDivider: false
        },
        {
          key: "type",
          name: "企业类型",
          type: "text",
          required: true,
          disabled: true,
          row: 8,
          isDivider: false
        },
        {
          key: "registerCapital",
          name: "注册资本",
          type: "text",
          required: true,
          disabled: true,
          row: 8,
          isDivider: false
        },
        {
          key: "establishDate",
          name: "成立日期",
          type: "time",
          required: true,
          disabled: true,
          row: 8,
          isDivider: false
        },
        {
          key: "legal",
          name: "法定代表人",
          type: "text",
          required: true,
          disabled: true,
          row: 8,
          isDivider: false
        },
        {
          key: "mobile",
          name: "法定代表人电话",
          type: "text",
          required: true,
          disabled: true,
          row: 8,
          isDivider: false
        },
        {
          key: "addressDetails",
          name: "注册地址",
          type: "text",
          required: true,
          disabled: true,
          row: 8,
          isDivider: false
        },
        {
          key: "certificatePicPath",
          name: "营业执照",
          type: "card",
          accept: [".jpg", ".jpeg", ".png", ".bmp"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },

        {
          key: "businessScope",
          name: "经营范围",
          type: "textarea",
          required: true,
          disabled: true,
          row: 24,
          isDivider: true
        },
        {
          key: "creditno",
          name: "统一社会信用代码",
          type: "text",
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "actualController",
          name: "实际控制人",
          type: "text",
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "controllerPhone",
          name: "实际控制人电话",
          type: "text",
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "businessAddress",
          name: "经营地址",
          type: "text",
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "code",
          name: "中征码或机构信用代码",
          type: "code",
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        }
      ]
    },
    {
      name: "业务数据",
      list: [
        {
          key: "customerInfoTable",
          name: "客户信息表",
          type: "file",
          template: "http://AAA.pdf", //模板
          describe: [
            "股权结构填写按照新版公司章程内容填写;",
            "关键人员信息信用状况，根据其个人信用信息查询授权书填写",
            "支持.xls、.xlsx格式，大小不超过2M"
          ], //描述
          accept: [".xls", ".xlsx"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },

        {
          key: "salesFlow",
          name: "销售流水",
          type: "file",
          template: "http://AAA.pdf", //模板
          describe: [
            "支持.jpg、.jpeg、.png、.pdf、.bmp、.doc、.docx、.xls、.xlsx格式，大小不超过2M"
          ], //描述
          accept: [
            ".jpg",
            ".jpeg",
            ".png",
            ".pdf",
            ".bmp",
            ".doc",
            ".docx",
            ".xls",
            ".xlsx"
          ], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },

        {
          key: "controllingPersonInfoTable",
          name: "实际控制人信息表",
          type: "file",
          template: "http://AAA.pdf", //模板
          describe: [
            "车辆、股票、基金、债券等内容，请据实填写，作为公司申请授信及增信时辅助说明资料。",
            "支持 .jpg、.jpeg、.png、.pdf、.bmp格式，大小不超过2M"
          ], //描述
          accept: [".jpg", ".jpeg", ".png", ".pdf", ".bmp"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },

        {
          key: "enterpriseCreditReportAuthorization",
          name: "企业信用报告查询授权书",
          type: "file",
          template: "http://AAA.pdf", //模板
          describe: [
            "支持 .jpg、.jpeg、.png、.pdf、.bmp、.doc、.docx、.xls、.xlsx格式，大小不超过2M"
          ], //描述
          accept: [
            ".jpg",
            ".jpeg",
            ".png",
            ".pdf",
            ".bmp",
            "..doc",
            ".docx",
            ".xls",
            ".xlsx"
          ], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },

        {
          key: "financialStatements",
          name: "财务报表",
          type: "file",
          template: "http://AAA.pdf", //模板
          describe: [
            "请您上传近期及前三年的财务报表，请结合自己公司成立年限按要求上传2.支持.xls、.xlsx格式，大小不超过2M"
          ], //描述
          accept: [".xls", ".xlsx"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "personalCreditInfoQueryAuthorization",
          name: "个人信用信息查询授权书",
          type: "file",
          template: "http://AAA.pdf", //模板
          describe: [
            "支持 .jpg、jpeg、.png、.pdf、.bmp、.doc、.docx、.xls、.xlsx格式，大小不超过2M"
          ], //描述
          accept: [
            ".jpg",
            ".jpeg",
            ".png",
            ".pdf",
            ".bmp",
            ".doc",
            ".docx",
            ".xls",
            ".xlsx"
          ], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        }
      ]
    },
    {
      name: "授信资料",
      list: [
        {
          key: "companyIntroduction",
          name: "公司简介",
          type: "file",
          template: "http://AAA.pdf", //模板
          describe: [
            "支持 .jpg、.jpeg、.png、.pdf、.bmp、.doc、.docx、.xls、.xlsx格式，大小不超过2M"
          ], //描述
          accept: [
            ".jpg",
            ".jpeg",
            ".png",
            ".pdf",
            ".bmp",
            ".doc",
            ".docx",
            ".xls",
            ".xlsx"
          ], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "legalIdCardFront",
          name: "人像面",
          decribe: "实际控股人身份证(正反面)复印件",
          type: "card",
          accept: [".jpg", ".jpeg", ".png", ".bmp"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "legalIdCardBack",
          name: "国徽面",
          decribe: "实际控股人身份证(正反面)复印件",
          type: "card",
          accept: [".jpg", ".jpeg", ".png", ".bmp"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "financeIdCardFront",
          name: "人像面",
          decribe: "财务负责人身份证(正反面)复印件",
          type: "card",
          accept: [".jpg", ".jpeg", ".png", ".bmp"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        },
        {
          key: "financeIdCardBack",
          name: "国徽面",
          decribe: "财务负责人身份证(正反面)复印件",
          type: "card",
          accept: [".jpg", ".jpeg", ".png", ".bmp"], //接受类型
          required: true,
          disabled: false,
          row: 8,
          isDivider: false
        }
      ]
    }
  ]
};

for (let i = 0; i < data.list.length; i++) {
  const innerList = data.list[i].list;
  for (let j = 0; j < innerList.length; j++) {
    const { required, key, name, type } = innerList[j];

    if (required) {
      data.rules[key] = {
        text: [
          {
            required: true,
            message: `请输入${name}`,
            trigger: ["change", "blur"]
          }
        ],
        textarea: [
          {
            required: true,
            message: `请输入${name}`,
            trigger: ["change", "blur"]
          }
        ],
        time: [
          {
            required: true,
            message: `请选择${name}`,
            trigger: ["change", "blur"]
          }
        ],
        file: [
          {
            required: true,
            message: `请上传${name}`,
            trigger: ["change", "blur"]
          }
        ],
        card: [
          {
            required: true,
            message: `请上传${name}`,
            trigger: ["change", "blur"]
          }
        ],
        code: [
          {
            validator: (rule, value, callback) => {
              if (!value) {
                callback(new Error(`请选择${name}`));
                return false;
              } else if (value && !value.code) {
                callback(new Error(`请输入内容`));
                return false;
              } else {
                return true;
              }
            },
            trigger: ["change", "blur"]
          }
        ]
      }[type];
    }
  }
}

export default data;
